package edu.android.proyecto.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import edu.android.proyecto.R;
import edu.android.proyecto.beans.Mesa;

public class ListMesaAdapter extends ArrayAdapter<Mesa> {
	
	private ArrayList<Mesa> items = null;
	Mesa o = null;
	public ListMesaAdapter(Context context, int textViewResourceId,ArrayList<Mesa> mesas) {
		super(context, textViewResourceId, mesas);
		this.items = mesas;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		o = items.get(position);
		
		View v = convertView;
		if(v== null){
			LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inflater.inflate(R.layout.celda_mesa,null);
		}
		LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		v = inflater.inflate(R.layout.celda_mesa,null);
		
		if(o!=null){
			TextView tv_idMesa = (TextView) v.findViewById(R.id.textView1);
			TextView tv_capacidad = (TextView) v.findViewById(R.id.textView2);
			
			if(tv_idMesa !=null){
				tv_idMesa.setText("Numero mesa :  "+o.getNumero()+"");
			}
			if(tv_capacidad !=null){
				tv_capacidad.setText("Capacidad mesa :  "+o.getCantidad()+"");
			}
		}
		
		return v;
	}

}
